﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Hkwl.WorldExpo.Merchant.Common;
using Hkwl.WorldExpo.Merchant.Model;
using Hkwl.WorldExpo.Merchant.Service;

namespace Hkwl.WorldExpo.Merchant.Web
{
    public partial class GroupModify : BaseCheckPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            int groupId = int.Parse(Request.QueryString["GroupId"]);
            if (!Page.IsPostBack)
            {
                NxGroup nxGroup = ServiceLocator.IClientService.GetNxGroupById(groupId);
                this.txtGroup.Text = nxGroup.GroupName;
                hidOldGroup.Value = nxGroup.GroupName;
            }
        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (txtGroup.Text != null)
            {
                NxGroup nxGroup = ServiceLocator.IClientService.GetNxGroupById(int.Parse(Request.QueryString["GroupId"]));
                nxGroup.GroupName = this.txtGroup.Text;
                if (ServiceLocator.IClientService.UpdateNxGroup(nxGroup))
                {
                    JavaScript.WriteJs("jAlert('" + (String)GetGlobalResourceObject("Default", "SAVE_SUCCESSFUL") + "','" + (String)GetGlobalResourceObject("Default", "NOTE") + "','GroupList.aspx')", this.Page);
                }
                else
                {
                    JavaScript.WriteJs("jAlert('" + (String)GetGlobalResourceObject("Default", "SAVE_ERROR") + "','" + (String)GetGlobalResourceObject("Default", "NOTE") + "','GroupList.aspx')", this.Page);
                }
            }
        }
    }
}
